package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.security.ConditionalOnDefaultWebSecurity;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author 快点干早点散
 * @Create 2025/3/28 11:42
 * Description:
 */
@EnableConfigurationProperties(MinioProperties.class)
@Configuration
////条件注入
//@ConditionalOnProperty(prefix ="minio", name = "endpoint")
public class MinioConfiguration {
    @Autowired
    private MinioProperties minioProperties;

    @Bean
    public MinioClient minioClient() {
        MinioClient minioClient = MinioClient.builder().endpoint(minioProperties.getEndpoint()).
                credentials(minioProperties.getUsername(), minioProperties.getPassword()).build();
        return minioClient;

    }
}
